home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d6
/
glazer.arc
/
RULEOF78.BAS
< prev
next >
Wrap
BASIC Source File
|
1988-10-07
|
2KB
|
53 lines
100 'Rule of 78s ("RULEOF78S")
110 CLS
120 COLOR 0,15 : PRINT "Rule of 78s" : COLOR 15,0
130 DEFDBL A-Z
140 DEFINT M-N
150 MONEYFMT$ = "$$##,###,###.##"
160 ' Define rounding function
170 DEF FNR (V) = SGN (V) * INT (ABS (V) * 100 + .5) / 100
180 ' Let user enter data
190 PRINT
200 PRINT "Do not enter dollar signs or commas"
210 PRINT
220 INPUT "Amount of loan: ", PNCPL
230 INPUT "Term (in months): ", NMONTHS
240 INPUT "Annual interest rate (in percent): ", AR
250 PRINT "Enter date of first payment"
260 INPUT " Month (1-12): ", MONTH
270 IF MONTH < 1 OR MONTH > 12 THEN PRINT "No such month" : GOTO 260
280 INPUT " Year (1900-2100): ", YEAR
290 IF YEAR < 1900 OR YEAR > 2100 THEN PRINT "Year out of range" : GOTO 280
300 ' Find monthly payment
310 PR = AR / 1200
320 IF PR <> 0 THEN PMT = PNCPL * PR / ( 1 - (1 + PR) ^ -NMONTHS) ELSE PMT = PNCPL / NMONTHS
330 PMT = FNR (PMT)
340 PRINT : PRINT "Monthly payment:" ; USING MONEYFMT$ ; PMT
350 TFC = PMT * NMONTHS-PNCPL 'Total finance charges
360 PRINT
370 ' Amortization
380 PRINT "Press Enter to see next month's results"
390 TOTALINTEREST = 0
400 MONTHNUM = YEAR * 12 + MONTH 'Number of months since date 0
410 FOR M = 1 TO NMONTHS
420 'Wait for user to press Enter
430 INPUT "", K$
440 'Finance charge for the month
450 INTERESTDUE = TFC * 2 * (NMONTHS - M + 1) / (NMONTHS * (NMONTHS + 1) )
460 TOTALINTEREST = TOTALINTEREST + INTERESTDUE
470 CURRENTPNCPL = PNCPL + TOTALINTEREST - M * PMT 'New principal
480 'Determine the date
490 YEAR = (MONTHNUM - 1) \ 12
500 MONTH = MONTHNUM - YEAR * 12
510 MONTHNUM = MONTHNUM + 1
520 ' Print the month's results
530 PRINT: PRINT
540 PRINT "Payment number: " ; M
550 PRINT "Date: " ; MONTH ; "/" ; YEAR
560 PRINT
570 PRINT "Principal: "; TAB(22); USING MONEYFMT$; CURRENTPNCPL
580 PRINT "Interest due: " ; TAB(22); USING MONEYFMT$; INTERESTDUE
590 PRINT "Cumulative interest: " ; TAB(22) ; USING MONEYFMT$; TOTALINTEREST
600 NEXT M
610 END